package controllers

import (
	"github.com/goravel/framework/contracts/http"
	"github.com/goravel/framework/facades"
	"goravel/packages/spider/core"
)

type SpiderController struct {
	//Dependent services
}

func NewSpiderController() *SpiderController {
	return &SpiderController{
		//Inject services
	}
}

func (r *SpiderController) Cookie(ctx http.Context) http.Response {
	cookie := ctx.Request().Input("cookie")
	facades.Storage().Put("cookie", cookie)
	return ctx.Response().Json(200, http.Json{
		"message": "Ok",
	})
}

// 组合搜索
func (r *SpiderController) Combination(ctx http.Context) http.Response {
	id := ctx.Request().InputInt("id")
	//根据关键词搜索视频并搜索评论
	core.AwemeAll(id)
	return ctx.Response().Json(200, http.Json{
		"data": "success",
	})
}
